package com.taotao.health.service.impl;

import com.taotao.common.security.utils.SecurityUtils;
import com.taotao.health.domain.MedicalRecord;
import com.taotao.health.mapper.MedicalRecordMapper;
import com.taotao.health.service.MedicalRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

/**
 * 就诊记录Service实现类
 */
@Service
public class MedicalRecordServiceImpl implements MedicalRecordService {

    @Autowired
    private MedicalRecordMapper medicalRecordMapper;

    @Override
    @Transactional
    public Long createMedicalRecord(Long doctorId, BigDecimal registrationFee, Long patientId) {
        MedicalRecord medicalRecord = new MedicalRecord();
        medicalRecord.setDoctorId(doctorId);
        medicalRecord.setPatientId(patientId);
        medicalRecord.setRegistrationFee(registrationFee);
        medicalRecord.setRegistrationStatus(0); // 初始状态
        
        // 插入记录，自增ID会自动设置到medicalRecord对象的id属性中
        medicalRecordMapper.insert(medicalRecord);
        
        // 返回自增主键ID
        return medicalRecord.getId();
    }
}
